using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace WeberTimeTracker.Models.Mapping
{
    public class ContactMap : EntityTypeConfiguration<Contact>
    {
        public ContactMap()
        {
            // Primary Key
            this.HasKey(t => t.Contact_ID);

            // Properties
            this.Property(t => t.First_Name)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Last_Name)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Phone)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(10);

            this.Property(t => t.Extension)
                .IsFixedLength()
                .HasMaxLength(10);

            this.Property(t => t.Email)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Contacts");
            this.Property(t => t.Contact_ID).HasColumnName("Contact_ID");
            this.Property(t => t.First_Name).HasColumnName("First_Name");
            this.Property(t => t.Last_Name).HasColumnName("Last_Name");
            this.Property(t => t.Phone).HasColumnName("Phone");
            this.Property(t => t.Extension).HasColumnName("Extension");
            this.Property(t => t.Email).HasColumnName("Email");
        }
    }
}
